<template>
  <div class="sequential-same" :style="{ 'flex-direction': direction }">
    <div class="sequential" :class="data.ring > 0 ? 'num-up' : 'num-down'">
      <span class="text">环比</span>
      <span class="icon" :class="data.ring > 0 ? 'rising' : 'falling'" v-if="data.ring"></span>
      <span class="text-number">{{ data.ring != 0 && data.ring ? Math.abs(data.ring) + '%' : '-' }}</span>
    </div>
    <div class="same" :class="data.same > 0 ? 'num-up' : 'num-down'">
      <span class="text">同比</span>
      <span class="icon" :class="data.same > 0 ? 'rising' : 'falling'" v-if="data.same"></span>
      <span class="text-number">{{ data.same != 0 && data.same ? Math.abs(data.same) + '%' : '-' }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'SequentialSame'
}
</script>
<script setup>
/**
 *     @desc    同环比
 *     @author  阳坤
 *
 * **/
import { ref } from 'vue'

const props = defineProps({
  data: {
    type: Object,
    default: () => {
      return {}
    }
  },
  direction: {
    type: String,
    default: ''
  }
})
</script>

<style scoped lang="less">
.sequential-same {
  width: 100%;
  display: flex;
  font-size: 14px;
  justify-content: space-between;

  .text {
    color: #666 !important;
    margin-right: 5px;
    word-break: keep-all;
  }

  .rising {
    background: url(../../assets/images/rising.png) no-repeat;
  }

  .falling {
    background: url(../../assets/images/falling.png) no-repeat;
  }

  .icon {
    display: inline-block;
    width: 8px;
    height: 12px;
    margin-right: 2px;
    background-size: 100% 100%;
  }

  .num-up {
    color: #f53f3f;
    // margin-right: 10px;
    display: flex;
    align-items: center;
  }

  .num-down {
    color: #19bc69;
    align-items: center;
    display: flex;
  }
}
</style>
